<?php

namespace app\index\controller;

use app\index\controller\Main;
use think\Db;

class Salem extends Main {
    
        
     public function __construct(\think\App $app = null) {
        parent::__construct($app);
         $_W['baseurl']=$this->request->domain(true);
         $_W['timestamp'] =time();
         $_W['sysset']=$this->sysset;
         $this->view->assign('_W', $_W);
     }

    public function cards() {

        $_GPC = input();
        $title = '领券记录';
         $_GPC['page']=isset($_GPC['page'])?$_GPC['page']:1;
        $_GPC['limit']=isset($_GPC['limit'])?$_GPC['limit']:10;
        
      
        
        $page = max(intval($_GPC['page']), 1);
        $limit = max(intval($_GPC['limit']), 10);

        $row = Db::name('sale_card')
                ->alias('c')
                ->join('member m', 'c.member_id=m.id')
                ->field('c.*,m.avatar,m.nickname')
                ->where(array('c.sale_id' => $_GPC['id']));
        $users = $row->order('c.createtime DESC')->page($page, $limit)->select();
        $count = $row->count();
        $this->view->assign('_GPC', $_GPC);
          $this->view->assign('page', $page);
        $this->view->assign('limit', $limit);
        $this->view->assign('title', $title);
        $this->view->assign('count', $count);
        $this->view->assign('users', $users);
        return $this->view->fetch();
    }

    public function users() {

        $_GPC = input();
        $title = '参与用户';
                 $_GPC['page']=isset($_GPC['page'])?$_GPC['page']:1;
        $_GPC['limit']=isset($_GPC['limit'])?$_GPC['limit']:10;
        
       
        
        $page = max(intval($_GPC['page']), 1);
        $limit = max(intval($_GPC['limit']), 10);

        $row = Db::name('member_sale')->where(array('sale_id' => $_GPC['id']));
        $users = $row->order('createtime', 'DESC')->page($page, $limit)->select();
        $count = $row->count();
         $this->view->assign('_GPC', $_GPC);
         $this->view->assign('page', $page);
        $this->view->assign('limit', $limit);
        $this->view->assign('title', $title);
        $this->view->assign('count', $count);
        $this->view->assign('users', $users);
        return $this->view->fetch();
    }

    public function verifyer() {

        $_GPC = input();
        $title = '核销员管理';
        
                 $_GPC['page']=isset($_GPC['page'])?$_GPC['page']:1;
        $_GPC['limit']=isset($_GPC['limit'])?$_GPC['limit']:10;
        
      
        
        $page = max(intval($_GPC['page']), 1);
        $limit = max(intval($_GPC['limit']), 1);
        
        

        $row = Db::name('sale_verifyer')->alias('v')
                ->join('member m', 'v.member_id=m.id')
                ->field('v.*,m.avatar,m.nickname')
                ->where(array('v.sale_id' => $_GPC['id']));
        $users = $row->page($page, $limit)->order('v.createtime', 'DESC')->select();
        $count = $row->count();
         $this->view->assign('_GPC', $_GPC);
          $this->view->assign('page', $page);
        $this->view->assign('limit', $limit);
        $this->view->assign('title', $title);
        $this->view->assign('count', $count);
        $this->view->assign('users', $users);
        return $this->view->fetch();
    }

    public function videodata() {

        $_GPC = input();
        $title = '用户视频数据';
                 $_GPC['page']=isset($_GPC['page'])?$_GPC['page']:1;
        $_GPC['limit']=isset($_GPC['limit'])?$_GPC['limit']:10;
        
        
        $page = max(intval($_GPC['page']), 1);
        $limit = max(intval($_GPC['limit']), 10);

        $row = Db::name('member_video')
                ->where(array('member_id' => $_GPC['mid'], 'sale_id' => $_GPC['sale_id']));
        $list = $row->order('createtime', 'DESC')->page($page, $limit)->select();
        
        
        //print_r($list);exit;
        $count = $row->count();
          $this->view->assign('_GPC', $_GPC);
        $this->view->assign('page', $page);
        $this->view->assign('limit', $limit);
        $this->view->assign('title', $title);
        $this->view->assign('count', $count);
        $this->view->assign('list', $list);
        return $this->view->fetch();
    }

}
